import numpy as np
from numpy.random import randint
import cv2
# from test import testDef
from utils.data_multi import data_multi
from utils.data_multi import vhfilp


def ranGaussian(img):
    '''
    进行一个高斯的模糊
    '''
    kenerl_size_list = [(3, 3), (5, 5)]
    sigma_list = [0, 0.25, 0.5, 0.75, 1]
    img = cv2.GaussianBlur(img, kenerl_size_list[randint(0, 1)], sigma_list[randint(0, 4)])
    return img



def scanAndMedi(img):
    '''
    一种简单前处理
    '''
    hh, ww = img.shape[:2]
    medi_value = np.median(img, axis = 0)
    img_sw = img
    for i in range(hh):
        if i in range(112-12, 112+12):
                continue
        for j in range(ww): 
            dot = img_sw[i][j]
            medi_medi = np.min(medi_value[max(0, i-5):min(i+5, hh)], axis = 0)
            for bgr in range(len(dot)):
                if dot[bgr] >= medi_medi[bgr]*1.5:
                    dot[bgr] = medi_medi[bgr]
    # img = cv2.blur(img, (5, 5))
    return img_sw


def dataMulti(img):
    '''
    多特征增益
    '''
    img = data_multi(img)
    return img


def vhFlip(img):
    img = vhfilp(img)
    return img

# def testConve(img):
#     '''
#     导入外置包
#     '''
#     img = testDef(img)